﻿@model EbayApplication.Models.Product

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset class="form-horizontal">
        <legend>Product</legend>

        @Html.HiddenFor(model => model.Id)
        @Html.HiddenFor(model => model.DateAdded)

        <div class="control-group"></div>
        <div class="control-group">
            @Html.LabelFor(model => model.Title, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.Title)
                @Html.ValidationMessageFor(model => model.Title, null, new { @class = "help-inline" })
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Description, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.Description)
                @Html.ValidationMessageFor(model => model.Description, null, new { @class = "help-inline" })
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Price, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.Price)
                @Html.ValidationMessageFor(model => model.Price, null, new { @class = "help-inline" })
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.StartingPrice, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.StartingPrice)
                @Html.ValidationMessageFor((model => model.StartingPrice), null, new { @class = "help-inline" })
            </div>
        </div>

        @*<div class="control-group">
            @Html.LabelFor(model => model.DeliveryTime, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.DeliveryTime)
                @Html.ValidationMessageFor((model => model.DeliveryTime), null, new { @class = "help-inline" })
            </div>
        </div>*@

        <div class="control-group">
            @Html.LabelFor(model => model.Condition, new { @class = "control-label" })
            <div class="controls">
                @Html.DropDownListFor(model => model.Condition, new SelectList(Enum.GetValues(typeof(EbayApplication.Models.Condition))))

                @Html.ValidationMessageFor(model => model.Condition, null, new { @class = "help-inline" })
            </div>
        </div>

        @*<div class="control-group">
            @Html.LabelFor(model => model.AuctionType, new { @class = "control-label" })
            <div class="controls">
                @Html.DropDownListFor(model => model.AuctionType, new SelectList(Enum.GetValues(typeof(EbayApplication.Models.AuctionType))))

                @Html.ValidationMessageFor(model => model.AuctionType, null, new { @class = "help-inline" })
            </div>
        </div>*@

        <div class="control-group">
            @Html.LabelFor(model => model.ImageUrl, new { @class = "control-label" })
            <div class="controls">
                @(Html.Kendo()
                .Upload()
                .Name("upload")
                .Multiple(false)
                .Async(async =>
                {
                    async.AutoUpload(true)
                        .Save("UploadedFiles", "Products");
                })
                .Events(e => e.Complete("imageUrl")))
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Category.Id, new { @class = "control-label" })
            <div class="controls">
                @Html.DropDownListFor(model => model.Category.Id, (IEnumerable<SelectListItem>)ViewBag.Categories)
                @Html.ValidationMessageFor(model => model.Category.Id, null, new { @class = "help-inline" })
            </div>
        </div>

        <input id="hiddenImageUrl" type="hidden" value="" name="ImageUrl" />

        <div class="form-actions no-color">
            <input type="submit" value="Create" class="btn btn-primary" id="sender" />
        </div>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

<script>
 
    function imageUrl() {
        var fu1 = $(".k-filename").first();
        $("#hiddenImageUrl").val(fu1.attr("title"));
    }
</script>